package lib.datatypes;

/**
 * Abstraction for an long point in geometry
 * @author dolphinigle
 */
public class TwoDimensionalLongPoint {

  /**
   * X coordinate of this point
   */
  private long x_;
  /**
   * Y coordinate of this point
   */
  private long y_;

  /**
   * Getter for x
   * @return x
   */
  public long x() {
    return x_;
  }

  /**
   * Getter for y
   * @return y
   */
  public long y() {
    return y_;
  }

  /**
   * Constructs a new point
   * @param x x coordinate of the point
   * @param y y coordinate of the point
   */
  public TwoDimensionalLongPoint(long x, long y) {
    x_ = x;
    y_ = y;
  }

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof TwoDimensionalLongPoint)) return false;
    TwoDimensionalLongPoint that = (TwoDimensionalLongPoint) obj;
    return that.x() == this.x() && that.y() == this.y();
  }

  @Override
  public int hashCode() {
    int h1, h2;
    h1 = Long.valueOf(this.x()).hashCode();
    h2 = Long.valueOf(this.y()).hashCode();
    long trynew = (long)h1 * Integer.MAX_VALUE + (long)h2;
    return Long.valueOf(trynew).hashCode();
  }

}
